//
//  MessItemTableViewCell.m
//  YJlandlord
//
//  Created by 文彬 on 2018/6/26.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "MessItemTableViewCell.h"

@implementation MessItemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.titleLabel.textColor = kTitleColor;
    self.detailLabel.textColor = kSecTitleColor;
    
    //用代码设置约束 方便动态修改
    [self.iconImgView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.width.equalTo(@25);
        make.height.equalTo(@25);
        make.centerY.equalTo(self.centerY);
    }];
    
    [self.arrowImgView makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.width.equalTo(@8);
        make.height.equalTo(@15);
        make.centerY.equalTo(self.centerY);
    }];
    
    [self.detailLabel makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowImgView.left).offset(-5);
        make.height.equalTo(@25);
        make.centerY.equalTo(self.centerY);
        make.width.equalTo(@110);
    }];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImgView.right).offset(5);
        make.right.equalTo(self.detailLabel.left).offset(-5);
        make.height.equalTo(@25);
        make.centerY.equalTo(self.centerY);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)showImage:(BOOL)showImage
{
    if (showImage) {
        
        self.iconImgView.hidden = NO;
        
        [self.titleLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImgView.right).offset(5);
            make.height.equalTo(@21);
            make.right.equalTo(self.detailLabel.left);
            make.centerY.equalTo(self.centerY);
        }];
    }
    else{
        
        self.iconImgView.hidden = YES;
        
        [self.titleLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@15);
            make.height.equalTo(@21);
            make.right.equalTo(self.detailLabel.left);
            make.centerY.equalTo(self.centerY);
        }];
    }
}

- (void)showArrow:(BOOL)showArrow{
    if (showArrow) {
        
        self.arrowImgView.hidden = NO;
        [self.detailLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.arrowImgView.left).offset(-5);
            make.height.equalTo(@25);
            make.centerY.equalTo(self.centerY);
            make.width.equalTo(@110);
        }];
    }
    else{
        self.arrowImgView.hidden = YES;
        [self.detailLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-10);
            make.height.equalTo(@25);
            make.centerY.equalTo(self.centerY);
            make.width.equalTo(@110);
        }];
    }
}

- (void)showDetailLabe:(BOOL)showDetail{
    if (showDetail) {
        self.detailLabel.hidden = NO;
        [self.titleLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImgView.right).offset(5);
            make.height.equalTo(@21);
            make.right.equalTo(self.detailLabel.left);
            make.centerY.equalTo(self.centerY);
        }];
    }
    else{
        self.detailLabel.hidden = YES;
        [self.titleLabel remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImgView.right).offset(5);
            make.height.equalTo(@21);
            make.width.equalTo(@(self.frame.size.width-60));
            make.centerY.equalTo(self.centerY);
        }];
    }
}

@end
